<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8">
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <!--[if lt IE 9]-->
    <script type="text/javascript" src="../../../../lib/html5shiv.js?rev=@@hash"></script>
    <script type="text/javascript" src="../../../../lib/respond.min.js?rev=@@hash"></script>
    <!--[endif]-->
    <link rel="stylesheet" type="text/css" href="../../../../static/h-ui/css/H-ui.min.css" />
    <link rel="stylesheet" type="text/css" href="../../../../static/h-ui.admin/css/H-ui.admin.css" />
    <link rel="stylesheet" type="text/css" href="../../../../lib/Hui-iconfont/1.0.8/iconfont.css" />
    <link rel="stylesheet" type="text/css" href="../../../../static/h-ui.admin/skin/default/skin.css" id="skin" />
    <link rel="stylesheet" type="text/css" href="../../../../static/h-ui.admin/css/style.css" />
    <link rel="stylesheet" type="text/css" href="../../../../ht-css/Project.css" />
    <link rel="stylesheet" type="text/css" href="../../../../ht-css/style-q.css" />
    <!--[if IE 6]-->
    <script type="text/javascript" src="../../../../lib/DD_belatedPNG_0.0.8a-min.js?rev=@@hash"></script>
    <script>DD_belatedPNG.fix('*');</script>
    <!--[endif]-->
    <title>上传安装包</title>
</head>
<body>
<nav class="breadcrumb">移动端管理 <span class="c-gray en">&gt;</span> <span onclick="returnVer()" style="cursor:pointer">ios版本号管理</span> <span class="c-gray en">&gt;</span> 上传安装包 <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px ;display:block" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a></nav>
<article class="page-container">
    <!--<form class="ml-20 mr-20" id="form-member"  method="post">-->
    <div class="bk-gray bg-1 pd-20">
        <div class="bk-gray pd-30 col-5-2" style="margin: 0 auto;">
            <div>当前版本安装包版本为<span id="newFileNameOne"></span></div>
            <div class="mt-15">
                <input type="button" class="btn btn-secondary size-S radius" value="查看当前下载路径" onclick="seePath()">
                <input type="button" class="btn btn-secondary size-S radius ml-10" value="添加最新的ios包" onclick="addAndroid()">
                <input type="button" class="btn btn-secondary size-S radius ml-10" value="查看历史记录" onclick="seeUpload()">
            </div>
            <div class="mt-15">注：上传成功后自动覆盖之前的安装包</div>
        </div>

        <!--查看当前下载路径弹窗-->
        <div id="download-path" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="ture" style="border-radius: 8px;">
            <div class="modal-dialog" style="top:50%;margin-top:-100px">
                <div class="modal-content radius" style="height:200px;width:540px;">
                    <div class="modal-header"  >
                        <a class="close" style="margin-right: 5px;width: 22px;height: 22px;margin-top: 5px" data-dismiss="modal" aria-hidden="true" >×</a>
                    </div>
                    <div class="pl-30 mt-10"><b>当前版本安装包为</b><span id="newFileNameTwo"></span></div>
                    <div class="mt-10 pl-30 clearfix">
                        <label class="f-l lh-26">生成路径：</label>
                        <input type="text" class="input-text f-l radius" id="newPath" style="width:75%" value="http://127.0.0.1:32767/start.html#p=新增&g=1">
                    </div>
                    <div class="mt-20 text-r" style="padding-right:65px">
                        <input type="button" class="btn btn-secondary size-S radius ml-10" onclick="copyNewUrl()" value="复制链接">
                    </div>
                </div>
            </div>
        </div>
        <!--查看当前下载路径弹窗end-->

        <!--添加最新ios包弹窗-->
        <div id="add-android" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="ture" style="border-radius: 8px;">
            <div class="modal-dialog" style="top:50%;margin-top:-100px">
                <div class="modal-content radius" style="height:200px;width:540px;">
                    <div class="modal-header"  >
                        <a class="close" style="margin-right: 5px;width: 22px;height: 22px;margin-top: 5px" data-dismiss="modal" aria-hidden="true" >×</a>
                    </div>
                    <form id="appApkForm" method="post" enctype="multipart/form-data">
                        <div class="mt-10 pl-20">
                            <span class="btn-upload form-group">
                                <input class="input-text upload-url radius mr-10" type="text" name="appApkName" id="appApkName" style="margin-top:2px;height: 27px;" readonly>
                                <input type="button" class="btn btn-secondary btn-upload size-S radius"  value="选择文件">
                                <input type="file" id="appApkFile" name="file" style="margin-top:2px" class="input-file">
                                <!--上传路径-->
                                <input type="hidden" name="catalog" value="12">
                            </span>
                        </div>
                        <div class="mt-40 text-c">
                            <input type="submit" class="btn btn-secondary size-S radius ml-10" id="uploadAppApk" value="确&nbsp;&nbsp;定">
                            <input type="button" class="btn size-S radius ml-10" value="取&nbsp;&nbsp;消" onclick="closeSelect()">
                        </div>
                    </form>

                </div>
            </div>
        </div>
        <!--添加最新android包弹窗end-->

        <!--查看历史记录弹窗-->
        <div id="upload-record" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="ture" style="border-radius: 8px;">
            <div class="modal-dialog" style="top:50%;margin-top:-180px">
                <div class="modal-content radius" style="height:360px;width:540px;">
                    <div class="modal-header" style="border-bottom: none">
                        <h3 class="modal-title"><b class="ml-15">历史上传记录(android)</b></h3>
                        <a class="close" style="margin-right: 5px;width: 22px;height: 22px;margin-top: 5px" data-dismiss="modal" aria-hidden="true" >×</a>
                    </div>
                    <ul class="pl-30 pr-30" style="height:220px;overflow-y: auto" id="historyVersion">

                    </ul>
                    <div class="mt-10 text-r" style="padding-right:65px">
                        <input type="button" class="btn size-S radius ml-10" value="关&nbsp;&nbsp;闭" onclick="closeRecord()">
                    </div>
                </div>
            </div>
        </div>
        <!--查看历史记录弹窗end-->

        <!--上传成功弹窗-->
        <div id="upload-success" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="ture" style="border-radius: 8px;">
            <div class="modal-dialog" style="top:50%;margin-top:-100px">
                <div class="modal-content radius" style="height:200px;width:540px;">
                    <div class="modal-header" style="border-bottom: none">
                        <h3 class="modal-title"><b class="ml-15">上传成功</b></h3>
                        <a class="close" style="margin-right: 5px;width: 22px;height: 22px;margin-top: 5px" data-dismiss="modal" aria-hidden="true" >×</a>
                    </div>
                    <div class="mt-10 pl-30 clearfix">
                        <label class="f-l lh-26">生成路径：</label>
                        <input type="text" class="input-text f-l radius" style="width:75%" id="appApkPath" >
                    </div>
                    <div class="mt-20 text-r" style="padding-right:65px">
                        <input type="button" class="btn btn-secondary size-S radius ml-10" onclick="copyUrl()" value="复制链接">
                    </div>
                </div>
            </div>
        </div>
        <!--上传成功弹窗end-->

        <!--上传失败弹窗-->
        <div id="upload-defate" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="ture" style="border-radius: 8px;">
            <div class="modal-dialog" style="top:50%;margin-top:-100px">
                <div class="modal-content radius" style="height:200px;width:540px;">
                    <div class="modal-header" style="border-bottom: none">
                        <a class="close" style="margin-right: 5px;width: 22px;height: 22px;margin-top: 5px" data-dismiss="modal" aria-hidden="true" >×</a>
                    </div>
                    <div class="text-c f-24" style="height:120px;line-height: 120px"><b>上传失败请重新尝试</b></div>
                </div>
            </div>
        </div>
        <!--上传失败弹窗end-->
    </div>
    <!--</form>-->
</article>
<!--_footer 作为公共模版分离出去-->
<script type="text/javascript" src="../../../../lib/jquery/1.9.1/jquery.min.js?rev=@@hash"></script>
<script type="text/javascript" src="../../../../lib/layer/2.4/layer.js?rev=@@hash"></script>
<script type="text/javascript" src="../../../../static/h-ui/js/H-ui.min.js?rev=@@hash"></script>
<script type="text/javascript" src="../../../../static/h-ui.admin/js/H-ui.admin.js?rev=@@hash"></script> <!--/_footer 作为公共模版分离出去-->
<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="../../../../lib/My97DatePicker/4.8/WdatePicker.js?rev=@@hash"></script>
<!--表单验证-->
<script type="text/javascript" src="../../../../lib/jquery.validation/1.14.0/jquery.validate.js?rev=@@hash"></script>
<script type="text/javascript" src="../../../../lib/jquery.validation/1.14.0/validate-methods.js?rev=@@hash"></script>
<script type="text/javascript" src="../../../../lib/jquery.validation/1.14.0/messages_zh.js?rev=@@hash"></script>
<script type="text/javascript" src="../../../../lib/datatables/1.10.0/jquery.dataTables.min.js?rev=@@hash"></script>
<script type="text/javascript" src="../../../../lib/laypage/1.2/laypage.js?rev=@@hash"></script>
<script type="text/javascript" src="../../../../ht-js/vue.min.js?rev=@@hash"></script>
<script src="../../../../ht-js/frame/doT.min.js?rev=@@hash"></script>
<script src="../../../../ht-js/public.js?rev=@@hash"></script>
<!--验证token-->
<script src="../../../../ht-js/verifyToken.js?rev=@@hash"></script>
<script src="../../../../ht-js/Project.js?rev=@@hash"></script>
<script src="../../../../ht-js/contract/jquery-form.js?rev=@@hash"></script>
<!--引入分页-->
<link rel="stylesheet" href="../../../../lib/pagination/pagination.css">
<script src="../../../../lib/pagination/jquery.pagination.js?rev=@@hash"></script>
<link type="text/css" rel="stylesheet" href="../../../../ht-js/operation-js/time-js/jedate.css">
<script type="text/javascript" src="../../../../ht-js/operation-js/time-js/jquery.jedate.js?rev=@@hash"></script>
<script>

    $(function () {
        $.ajax({
            /*root.appversions.insertVersionInfo*/
            url: 'https://'+ window.location.host +'/api/admin/abaseservice/version/queryAppVersionApkList',
            cache: false,  //禁用缓存
            type: "POST",
            dataType:'json',
            data: {
                "type": 20
            },
            success: function(obj){
                console.log(obj.data)
                if (obj.sub_code == 0){
                    $("#newFileNameOne").html('"'+obj.data[0].fileName+'"');
                    $("#newFileNameTwo").html('"'+obj.data[0].fileName+'"');
                }else {
                    layer.msg(data.sub_msg, {icon: 5,time:2000});
                }
            },
            error:function(data){
                alert("error"+data);
            }
        });
    })

    //返回版本号管理
    function returnVer(){
        $("body").load("ios_version.html");
    }

    //查看当前下载路径
    function seePath(){
        $.ajax({
            /*root.appversions.insertVersionInfo*/
            url: 'https://'+ window.location.host +'/api/admin/abaseservice/version/queryAppVersionApkList',
            cache: false,  //禁用缓存
            type: "POST",
            dataType:'json',
            data: {
                "type": 20
            },
            success: function(obj){
                console.log(obj.data)
                if (obj.sub_code == 0){

                    $("#newPath").val(obj.data[0].filePath);
                    $("#download-path").modal("show");

                }else {
                    layer.msg(data.sub_msg, {icon: 5,time:2000});
                }
            },
            error:function(data){
                alert("error"+data);
            }
        });

    }

    //添加最新android包弹窗
    function addAndroid() {
        $("#add-android").modal("show");
    }

    //查看历史记录
    function seeUpload(){
        $.ajax({
            /*root.appversions.insertVersionInfo*/
            url: 'https://'+ window.location.host +'/api/admin/abaseservice/version/queryAppVersionApkList',
            cache: false,  //禁用缓存
            type: "POST",
            dataType:'json',
            data: {
                "type": 20
            },
            success: function(obj){
                console.log(obj.data)
                if (obj.sub_code == 0){

                    $("#newPath").val(obj.data[0].filePath);

                    $.each(obj.data,function (i,version) {
                        console.log(version)
                        let versionHistory = '<li class="pb-10 mb-10" style="border-bottom:1px solid #dedede"><table border="1">'+
                            '<td align="center" valign="middle" style="width: 10%"><img class="bk-gray" src="../../../../img/favicon.ico" alt="" width="32" height="32"></td>'+
                            '<td align="center" valign="middle" style="width: 20%"><span class="ml-30">'+version.fileName+'</span></td>'+
                            '<td align="center" valign="middle" style="width: 70%"><span class="ml-30">'+version.createdAt+'</span></td></tr>'+
                            '</table></li>';
                        $("#historyVersion").append(versionHistory);
                    })

                    $("#upload-record").modal("show");

                }else {
                    layer.msg(data.sub_msg, {icon: 5,time:2000});
                }
            },
            error:function(data){
                alert("error"+data);
            }
        });

    }

    //关闭历史记录
    function closeRecord(){
        $("#upload-record").modal("hide");
    }

    //关闭添加android包弹窗
    function closeSelect() {
        $("#add-android").modal("hide");
    }
    $(function () {
        //上传app安装包
        $('#uploadAppApk').click(function(){
            $("#uploadAppApk").attr("disabled","disabled");
            $('#appApkForm').ajaxSubmit({
                url:'https://'+ window.location.host +'/api/admin/abaseservice/upload',
                type:"post",  //提交方式
                success:function (data) {
                    $("#uploadAppApk").attr("disabled",false);
                    $("#appApkPath").val(data[0].fullPath);
                    console.log(data[0].fullPath)
                    if (data[0].errorCode == 0) {
                        $("#upload-success").modal("show");   //上传成功弹出
                        layer.msg('上传成功!', {icon: 6,time:1000});
                    }else {
                        $("#upload-defate").modal("show");//上传失败弹出
                        layer.msg('上传失败!', {icon: 5,time:1000});
                    }
                },
                error:function () {
                    console.log(9999999)
                }
            })

            return false;
        })

    })
    //$("#upload-success").modal("show");   上传成功弹出
    //$("#upload-defate").modal("show");    上传失败弹出

    function copyUrl() {
        var Url=document.getElementById("appApkPath");
        Url.select(); // 选择对象
        document.execCommand("Copy"); // 执行浏览器复制命令
        layer.msg('复制成功！', {icon: 6,time:1000});
    }

    function copyNewUrl() {
        var Url=document.getElementById("newPath");
        Url.select(); // 选择对象
        document.execCommand("Copy"); // 执行浏览器复制命令
        layer.msg('复制成功！', {icon: 6,time:1000});
    }

</script>
</body>
</html>